import 'package:flutter/material.dart';
import 'package:flutter_shop/pages/member/select_dept/entity/dept_info.dart';
import 'package:flutter_shop/pages/member/select_dept/select_dept_model.dart';
import 'package:flutter_shop/widget/tree_select/tree_helper.dart';
import 'package:flutter_shop/widget/tree_select/tree_node.dart';
import 'package:flutter_shop/widget/tree_select/tree_state.dart';

/// Title:SelectDeptPage <br/>
/// Description: <br/>
/// author:xiemiao <br/>
/// date: 2020-04-16  <br/>
/// version 1.0 <br/>
class SelectDeptPage extends StatefulWidget {
  SelectDeptPage({Key key}) : super(key: key);

  @override
  _SelectDeptPageState createState() => _SelectDeptPageState();
}

class _SelectDeptPageState extends TreeState<SelectDeptPage, DeptInfo> {
  @override
  String getTitle() {
    return "选择部门";
  }

  @override
  TreeConfig getTreeConfig() {
    return TreeConfig(
      expandLevel: 1,
      isMultiSelect: true,
      isLinkSelect: true,
    );
  }

  @override
  Future<List<TreeNode>> getTreeList() async {
    List<DeptInfo> list = await SelectDeptModel().getDeptTree();
    //构建tree关系
    return TreeHelper.buildTree(list);
  }
}
